#!/usr/bin/env python
# coding=utf-8
# __author__ = 'Yunchao Ling'

import MySQLdb

d_file = open("desc2015.txt", "r")
q_file = open("qual2015.txt", "r")

DATABASE_NAME = 'lds'
HOST = '10.10.31.17'
PORT = '3306'
USER_NAME = 'lds'
PASSWORD = 'lds'
CHAR_SET = 'utf8'

conn = MySQLdb.connect(host=HOST, user=USER_NAME, passwd=PASSWORD, db=DATABASE_NAME, charset=CHAR_SET)

for line in d_file:
    line = line.rstrip()
    splitline = line.split("\t")
    id = splitline[1]
    name = splitline[2]
    cursor = conn.cursor()
    sql = "insert into tb_dds_mesh_descriptor (id,name) values(%s,%s)"
    params = (id, name)
    cursor.execute(sql, params)
    conn.commit()
    cursor.close()
d_file.close()

for line in q_file:
    line = line.rstrip()
    splitline = line.split("\t")
    id = splitline[1]
    name = splitline[2]
    cursor = conn.cursor()
    sql = "insert into tb_dds_mesh_qualifier (id,name) values(%s,%s)"
    params = (id, name)
    cursor.execute(sql, params)
    conn.commit()
    cursor.close()
q_file.close()

conn.close()




